use std::io;
fn main() {
    println!("请选择:\n 1.摄氏度\n 2.华氏度");
    let mut tem_type = String::new();
    io::stdin().read_line(&mut tem_type).expect("获取类型失败");
    let tem_type: i32 = tem_type.trim().parse().expect("设置类型值失败");

    init(tem_type)
}
fn init(temt: i32) {
    let tem_n = if temt == 1 {
        "摄氏度"
    } else if temt == 2 {
        "华氏度"
    } else {
        "无效类型"
    };
    if temt != 1 && temt != 2 {
        println!("输入的是无效值");
        return;
    }
    println!("tem_type{}", tem_n);
    println!("请输入{}", tem_n);
    let mut tem_s = String::new();
    io::stdin().read_line(&mut tem_s).expect("输入的值出错");
    let tem_v: f64 = tem_s.trim().parse().expect("温度无效");
    let res: Option<f64> = if temt == 1 {
        Some((tem_v * 1.8) + 32.0)
    } else if temt == 2 {
        Some((tem_v - 32.0) / 1.8)
    } else {
        None
    };
    match res {
        Some(num) => println!(" {}为{}", tem_n, num),
        None => println!("No number found"),
    }
}
